import { IsNumber, IsString, IsEnum, IsOptional } from 'class-validator';
import { MessageType } from '../entities/message.entity';
import { ApiProperty } from '@nestjs/swagger';

export class SendMessageDto {
  @ApiProperty({ description: '发送者 ID', example: 1 })
  @IsNumber()
  sender_id: number;

  @ApiProperty({ description: '接收者 ID', example: 2 })
  @IsNumber()
  receiver_id: number;

  @ApiProperty({ description: '消息内容', example: '你好' })
  @IsString()
  content: string;

  @ApiProperty({
    description: '消息类型',
    enum: MessageType,
    example: MessageType.USER_TO_DOCTOR,
  })
  @IsEnum(MessageType)
  message_type: MessageType;

  @ApiProperty({
    description: '额外信息，如话题 ID 等',
    example: '{"topicId": 10}',
    nullable: true,
  })
  @IsOptional()
  @IsString()
  extra_data?: string;
}

export class GetMessagesDto {
  @ApiProperty({ description: '用户 ID', example: 1 })
  @IsNumber()
  user_id: number;

  @ApiProperty({ description: '医生 ID', example: 2 })
  @IsNumber()
  doctor_id: number;
}

export class MarkReadDto {
  @ApiProperty({
    description: '需要标记为已读的消息 ID 数组',
    example: [1, 2, 3],
  })
  @IsNumber({}, { each: true })
  message_ids: number[];
}
